package com.jlpay.openapi.demo.ledger.merchconf;

import com.jlpay.open.jlpay.sdk.java.model.ledger.request.MerchIssueUpdateRequest;
import com.jlpay.open.jlpay.sdk.java.model.ledger.response.MerchIssueUpdateResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 *
 * @author dengwenning
 * @since 2024/8/30
 **/
public class MerchIssueUpdateService {

    private static final Logger LOGGER = LoggerFactory.getLogger(MerchIssueUpdateService.class);

    public static void main(String[] args) {
        MerchIssueUpdateRequest merchIssueUpdateRequest = buildMerchIssueUpdateRequest();
        MerchIssueUpdateResponse merchIssueUpdateResponse = JlpayOpenApiService.openMerchService()
                .post(merchIssueUpdateRequest, MerchIssueUpdateResponse.class);
        LOGGER.info("分账配置分账业务信息变更响应:{}", JsonUtils.toString(merchIssueUpdateResponse));
    }

    private static MerchIssueUpdateRequest buildMerchIssueUpdateRequest() {
        MerchIssueUpdateRequest merchIssueUpdateRequest = new MerchIssueUpdateRequest();
        merchIssueUpdateRequest.setOrgCode("50720711");
        merchIssueUpdateRequest.setMchId("849581183510017");
        merchIssueUpdateRequest.setLedgerModule("02");
        merchIssueUpdateRequest.setMaxSplitRate(20);
        merchIssueUpdateRequest.setSourceIds(Arrays.asList("jlpay/2024-08-30/e22bc590f433418483626fded04f3362.png", "jlpay/2024-08-30/e22bc590f433418483626fded04f3363.png"));
        merchIssueUpdateRequest.setFeeRate(2);
        merchIssueUpdateRequest.setPbthf("0");
        merchIssueUpdateRequest.setLowAmt(1);
        merchIssueUpdateRequest.setUpAmt(10);
        merchIssueUpdateRequest.setNotifyUrl("https://api.mch.weixin.qq.com/sns/notify");
        return merchIssueUpdateRequest;
    }
}
